<include file="Common/common" />
<style type="text/css">
	.layui-table tbody tr:hover, .layui-table thead tr, .layui-table-click, .layui-table-header, .layui-table-hover, .layui-table-mend, .layui-table-patch, .layui-table-tool {
		background-color: #7d7d7d;
	}
	@media screen and (min-width: 320px) and (max-width: 480px){
		.body{
			background: url(../../../../Public/img/mobile.png) no-repeat;background-size: 100% 100%;background-attachment: scroll
		}
	}
	@media only screen and (min-width: 480px) and (max-width: 1024px){
		.body{
			background: url(../../../../Public/img/background.png) no-repeat;background-size: 100% 100%;background-attachment: scroll
		}
	}
	@media only screen and (min-width: 1029px){
		.body{
			background: url(../../../../Public/img/background.png) no-repeat;background-size: 100%;background-attachment: scroll
		}
	}
</style>
<body class="body">
	<div class="layui-tab-item layui-show">
		<div class="layui-main">
			<br>
			<div class="layui-row layui-col-space30">
				<div class="layui-col-md6" style="margin-bottom:20px;">
					<div class="layui-form">
						<table class="layui-table" >
							<colgroup>
								<col width="100">
								<col width="100">
								<col width="100">
								<col width="100">
							</colgroup>
							<thead>
								<tr style="background: rgb(57,61,73)">
									<th colspan="4" style="text-align: center;font-size: 20px;color:rgb(240,222,112)" ><b>我的账号</b><if condition="$userInfo['status'] eq 0 ">（未激活）</if></th>
								</tr>
							</thead>
							<tbody style="background: #7d7d7d;color:rgb(240,222,112);">
								<tr>
									<td>账户名称</td>
									<td>{$userInfo['account']}</td>
									<td>用户姓名</td>
									<td>{$userInfo['truename']}</td>
								</tr>
								<tr>
									<td>直推人数</td>
									<td>{$userInfo['top_num']}</td>
									<td>团队人数</td>
									<td>{$userInfo['team_num']}</td>
								</tr>
								<tr>
									<td>任务积分</td>
									<td><span id="score_task">{$userInfo['score_task']}</span></td>
									<td>交易积分</td>
									<td>{$userInfo['score_trading']}</td>
								</tr>
								<tr>
									<td>动态秘钥</td>
									<td>{$userInfo['key_dynamic']}</td>
									<td>中心积分</td>
									<td>{$userInfo['score_center']}</td>
								</tr>
								<tr>
									<td>任务密钥</td>
									<td><span id="key_task">{$userInfo['key_task']}</span></td>
									<td></td>
									<td></td>
								</tr>
							</tbody>
						</table>

						<div class="layui-col-md12" >
					      	<if condition="$userInfo['status'] eq 0">
					      		<button  class="layui-btn layui-btn-fluid" id="btn-activate" style="margin-bottom:10px;color: rgb(240,222,112);font-size:16px;background: rgb(57,61,73)" >激活账号</button>
					      	</if>
				      	</div>

				      	<!-- <div class="layui-col-md12" >
					      	<if condition="$is_apply eq 0">
					      		<p style="margin-bottom:10px; color: red;">无法申请任务：{$msg}</p>
					      	</if>
				      	</div> -->

						<div class="layui-col-md12" >
					      	<!-- layui 2.2.5 新增 -->
    						<div class="layui-col-xs6" style="width: 49%;">
					      		<button id="btn-apply" class="layui-btn layui-btn-fluid  " style="color: rgb(240,222,112);background: rgb(57,61,73);font-size: 16px" >申请任务</button>
							</div>
							<div class="layui-col-xs6" style="width: 49%;float: right;">
						      	<button class="layui-btn layui-btn-fluid" style="color: rgb(240,222,112);font-size:16px;background: rgb(57,61,73)" onclick="parent.location.href='{:U('Index/recreation')}'">进入娱乐</button>
						    </div>
					    </div>
					</div>
				</div>
				<div class="layui-col-md6">
					<div class="layui-form">
						<table class="layui-table" >
							<colgroup>
								<col width="100">
								<col width="100">
								<col width="100">
								<col width="100">
							</colgroup>
							<thead>
								<tr>
									<th colspan="4" style="text-align: center;background: rgb(57,61,73)"><a href="{:U('Feedback/news_user')}" style="border-bottom:1px solid;font-size: 20px;color:rgb(240,222,112)"><b >网站公告</b></a></th>
								</tr>
							</thead>
							<thead  style="color: rgb(240,222,112);background: #7d7d7d">
								<tr>
									<th>发布日期</th>
									<th>最新公告</th>
								</tr>
							</thead>
							<tbody  style="color: rgb(240,222,112);background: #7d7d7d">
								<if condition="$topNews['id'] neq 0">
								<tr>
									<td><?php echo date('Y-m-d H:i:s',$topNews['createtime']) ?></td>
									<td><a href="#" style="border-bottom:1px solid;color: rgb(240,222,112);" onclick="fun_news(this,{$topNews['id']},'{$topNews['title']}')" >{$topNews['title']}</a></td>
								</tr>
								</if>
								<foreach name="newsList" item="vo">
								<tr>
									<td><?php echo date('Y-m-d H:i:s',$vo['createtime']) ?></td>
									<td><a href="#" style="border-bottom:1px solid;color: rgb(240,222,112);" onclick="fun_news(this,{$vo['id']},'{$vo['title']}')" >{$vo['title']}</a></td>
								</tr>
								</foreach>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>

<script type="text/javascript">
	var is_apply = 1;
	var reduceScore = {$activateScore};//扣除积分

	layui.use(['form'], function(){
		var form = layui.form;
		form.render();
		var ids = {$n_ids};

		if (ids.length > 0 && ids.length<= 1) {
			//直接推送内容
			layer.open({
				type: 2,
				title: '最新公告',
				shadeClose: false,
				closeBtn: 0,
				shade: 0.8,
				scrollbar: false,
				area: ['80%', '80%'],
				content: "/Feedback/newsDetail?id="+ids, //iframe的url
				btn: ['我已仔细阅读'],
			  	yes: function(index, layero){
			    	//按钮【按钮一】的回调
			    	//标记为已阅读
			    	$.ajax({
	                    type:'post',
	                    url:"{:U('Index/ctrl_IsRead')}",
	                    data:{id:ids},
	                    dataType:'json',
	                    success:function (rtJson) {
	                        layer.close(index);
	                    }
	                })
			    	
			  	}
			});
		}else if(ids.length > 1){
			//推送标题
			layer.open({
				type: 2,
				title: '最新公告',
				shadeClose: false,
				closeBtn: 0,
				shade: 0.8,
				scrollbar: false,
				area: ['80%', '80%'],
				content: "/Index/morePush?ids="+ids, //iframe的url
				btn: ['我已仔细阅读'],
			  	yes: function(index, layero){
			    	//按钮【按钮一】的回调
			    	layer.close(index);
			    	//标记为已阅读
			    	$.ajax({
	                    type:'post',
	                    url:"{:U('Index/ctrl_IsRead')}",
	                    data:{id:ids},
	                    dataType:'json',
	                    success:function (rtJson) {
	                        layer.close(index);
	                    }
	                })
			    	
			  	}
			});
		}
	});

	//查看新闻
	function fun_news(obj,id,name){
		layer.open({
			type: 2,
			title: name,
			shadeClose: true,
			shade: 0.8,
			scrollbar: false,
			closeBtn:1,
			area: ['80%', '80%'],
			content: "/Feedback/newsDetail?id="+id //iframe的url
		});
	}


	// 激活账号
	$("#btn-activate").click(function(){
		
		var uid = {$userInfo['id']};
		var score_center = {$userInfo['score_center']};
		if (score_center < reduceScore) {
            layer.msg('<span style="color: rgb(240,222,112);">中心积分小于'+reduceScore+'无法激活账号</span>');
			return false;
		}else{
			layer.confirm('确定激活？',{offset:'none'},function(index){
				$.ajax({
                    type:'post',
                    url:"{:U('Personal/ctrl_activate')}",
                    data:{uid:uid},
                    dataType:'json',
                    success:function (rtJson) {
                        layer.msg('<span style="color: rgb(240,222,112);">'+rtJson.msg+'</span>');
                        if (rtJson.code == 1) {
							setTimeout(function(){location.reload();}, 2000);
						}
                    }
                });
			});
		}
	});


	$("#btn-apply").click(function(){
		var registerScore = {$Think.config.registerScore};
		var uid = {$userInfo['id']};
		if (is_apply == 0) {
			return false;
		}else{
			layer.confirm('确定申请任务？',{offset:'none'},function(index){
				$.ajax({
                    type:'post',
                    url:"{:U('Personal/ctrl_applyTask')}",
                    data:{uid:uid},
                    dataType:'json',
                    success:function (rtJson) {
                    	if (rtJson.code == 1) {
                    		is_apply = 0;
                    		$("#btn-apply").addClass("layui-btn-disabled");

                    		var change_keytask = rtJson.data;

                    		var score_task = $("#score_task").text();
                    		var key_task = $("#key_task").text();
                    		$("#score_task").text((score_task - registerScore).toFixed(2));
                    		$("#key_task").text((key_task - change_keytask).toFixed(1));

                    	}

                        layer.msg('<span style="color: rgb(240,222,112);">'+rtJson.msg+'</span>');
                        
                    }
                });
			});	
		}
		
	});

	
</script>
<include file="Common/footer" />